import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import compressPlugin from 'vite-plugin-compression'
// https://vite.dev/config/
export default defineConfig({
  plugins: [react(),
    // vite打包，压缩gzip
    compressPlugin({
      algorithm:'gzip'
    }),
    // my-plugin  console.info替换console.log
    {
      name:'my-plugin',
      transform(code){
        return code.replace(/console\.log/g,'console.info')
      }
    }
  ],
  // @
  resolve:{
    alias:{
      '@':path.resolve(__dirname,'src')
    }
  },
  // console.log
  esbuild:{
    drop:['console','debugger']
  },
   server: {
    proxy: {
      '/api': {
        target: 'http://blogapi.shbwyz.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
    },
  }
})

// 
// try_files $uri $uri/  /index.html;

// loaction ^~/api/ {
//   proxy_pass http://blogapi.shbwyz.com/;
// }
